package com.yifei.controller.system;

import com.yifei.annotation.RateLimiter;
import com.yifei.annotation.RateRule;
import com.yifei.model.result.Result;
import com.yifei.service.system.SysOperateLogService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


/**
 * 日志(SysOperateLog)表控制层
 *
 * @author yiFei
 * @since 2023-11-03 14:49:48
 */
@Api(tags = "日志(log)")
@RestController
@RequestMapping("log")
public class SysOperateLogController {

    private static final Logger log = LoggerFactory.getLogger(SysOperateLogController.class);
    /**
     * 日志(SysOperateLog)对象
     */
    @Autowired
    private SysOperateLogService sysOperateLogService;

    @GetMapping("/test")
    @RateLimiter(rules = {@RateRule()})
    public Result<Object> test() {
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return Result.success(dateTimeFormatter.format(now));
    }

    @GetMapping("/test/aaa")
    public Result<Object> testAaa() {
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return Result.success(dateTimeFormatter.format(now));
    }

}

